﻿// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.SelfIssuedAuthRSAPKCS1SignatureDeformatter
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 8E14765A-6610-409A-BA36-099A0642905D
// Assembly location: E:\git\ALLIDA\windll\infocard.exe

using System.Security.Cryptography;

namespace Microsoft.InfoCards
{
  internal class SelfIssuedAuthRSAPKCS1SignatureDeformatter : RSAPKCS1SignatureDeformatter
  {
    private RSA m_rsaKey;
    private string m_strOID;

    public SelfIssuedAuthRSAPKCS1SignatureDeformatter()
    {
    }

    public SelfIssuedAuthRSAPKCS1SignatureDeformatter(AsymmetricAlgorithm key)
      : base(key)
    {
      this.m_rsaKey = (RSA) key;
    }

    public override void SetKey(AsymmetricAlgorithm key)
    {
      base.SetKey(key);
      this.m_rsaKey = (RSA) key;
    }

    public override void SetHashAlgorithm(string strName)
    {
      base.SetHashAlgorithm(strName);
      this.m_strOID = CryptoConfig.MapNameToOID(strName);
    }

    public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature)
    {
      if (this.m_strOID != null && this.m_rsaKey != null && (rgbHash != null && rgbSignature != null) && this.m_rsaKey is SelfIssuedAuthRSACryptoProvider)
        return ((SelfIssuedAuthRSACryptoProvider) this.m_rsaKey).VerifyHash(rgbHash, this.m_strOID, rgbSignature);
      return base.VerifySignature(rgbHash, rgbSignature);
    }
  }
}
